package com.cslg.ac.demo.dao.user;

import com.cslg.ac.demo.dao.user.po.UserPO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserDAO {
    final String USER_TABLE = "e_user";
    final String INSERT_FIELD = "id,userName,password,salt,userType";
    final String SELECT_FIELD = "id,userName,password,salt,userType";

    @Insert({"insert into ", USER_TABLE, "(", INSERT_FIELD, ") values( #{id},#{userName}, #{password}, #{salt}, #{userType})"})
    void Insert(UserPO userPO);
    @Select({"select ",SELECT_FIELD," from ",USER_TABLE," where id = #{id}"})
    UserPO SelectById(@Param("id") int id);
    @Select({"select ",SELECT_FIELD," from ",USER_TABLE," where userName = #{userName}"})
    UserPO SelectByName(@Param("userName") String userName);
    @Select({"select id from ",USER_TABLE," where userName = #{phone}"})
    Integer selectIdByPhone(@Param("phone")String phone);

}
